# -*- coding:utf-8 -*-
import socket
import uuid
import json
import requests
import time
REQUESTURL = 'http://192.168.1.66:5005'
headers = {'Content-Type':'application/x-www-form-urlencoded'}
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(('139.196.189.46',8080))
# s.connect(('127.0.0.1',8080))
END = 'This is the end marker'.encode('utf-8')
while 1:
    # data = 'init'
    # data = data.encode('utf-8')
    # s.send(data)
    data=s.recv(8192000)
    try:
        data = data.decode()
        print(data)
        data = json.loads(data)
    except:
        continue
    print('###################################################################')
    print('客户端接收的信息为',data)         #输出变量
    url = REQUESTURL + data[0]['url']
    print(url)
    params = data[1]
    r = requests.post(url,data=params,headers= headers)
    res = r.text
    res = res.encode('utf-8')
    s.send(res)
    print('已将请求数据发送socketServer',res)
s.close()
